// SMTPSocket.h: interface for the CSMTPSocket class.
//
//////////////////////////////////////////////////////////////////////

#ifndef _SEMAILLIB_SMTPSOCKET_H
#define _SEMAILLIB_SMTPSOCKET_H

#ifdef _MSC_VER
#pragma warning( disable : 4786 )
#endif

#include "Sockets/TcpSocket.h"
#include "Sockets/SocketHandler.h"
#include "Email.h"

class CSMTPSocket  : public TcpSocket
{
public:
	void SetSmtpHost(const std::string& host);
	void SetSmtpPort(unsigned int port);
	void SetSmtpUsername(const std::string& usr);
	void SetSmtpPassword(const std::string& pwd);

	bool Connect();

	void SendMail(CEmail * pMail);
	bool IsMailSent();

	CSMTPSocket(ISocketHandler& h);
	virtual ~CSMTPSocket();

	/** Called when a connection has completed. */

	virtual void OnConnect();
	/** Called when a complete line has been read and the socket is in
	 * line protocol mode. */
	virtual void OnLine(const std::string& );
	/** Called on connect timeout (5s). */
	virtual void OnConnectFailed();

private:
	std::string	m_strSmtpHost;
	unsigned int	m_nSmtpPort;
	std::string	m_strSmtpUsr;
	std::string	m_strSmtpPwd;

	CEmail	*m_pMail;

	bool	m_bMailSent;

	std::string m_strLastCmd;

	unsigned int	m_nMailMaxSize;
};

#endif 